<template>
	<view class="page" :style="'background-image: url('+indexBg+');'">
    <u-navbar :fixed="false" title="查看" placeholder bgColor="transparent"></u-navbar>
    <view class="detail-box u-m-t-48 u-m-b-32">
      <view class="detail-name">{{ form.title }}</view>
      <view class="detail-tel">{{ form.createTime }}</view>
      <view class="detail-box-content u-m-b-28" v-for="item in gwNoticeFileList">
        {{ item.note || '-' }}
        <view class="u-m-t-32 u-text-center" v-if="item.url"><image :src="item.url" style="width: 80%;" mode="widthFix" /></view>
      </view>
    </view>
	</view>
</template>

<script>
import { getGwnotice, setReadGwnotice } from '@/api/index'

export default {
  data() {
    return {
      indexBg: 'https://gowork365.com/prod-api/profile/mini/index/indexBg1.png',
      avatar: 'https://gowork365.com/prod-api/profile/mini/index/enterpriseLogo.png',
      id: '',
      userId: '',
      form: {},
      gwNoticeFileList: [],
    }
  },
  onLoad(options) {
    if(options.id) {
      this.id = options.id
      this.getForm()
    }
    if(options.userId) {
      this.userId = options.userId
      this.getRead()
    }
  },
  methods: {
    getForm() {
      uni.showLoading({ mask: true })
      getGwnotice(this.id).then(response => {
        uni.hideLoading()
        this.form = response.data;
        response.data.gwNoticeFileList.forEach(v => {
          if(v.url) {
            v.url = this.baseUrl + v.url
          }
        })
        this.gwNoticeFileList = response.data.gwNoticeFileList;
      });
    },
    getRead() {
      setReadGwnotice({id: this.id, userId: this.userId})
    }
  }
}
</script>

<style lang="scss" scoped>
.page{
	width: 750rpx;
	min-height: 100vh;
  background: #F4F7F6;
  position: relative;
  background-repeat: no-repeat;
  background-size: 750rpx 348rpx;
  padding-bottom: 180rpx;
  .detail-box {
    width: 686rpx;
    margin: 0 auto;
    padding: 32rpx;
    background: #FFFFFF;
    box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(11,102,97,0.2);
    border-radius: 16rpx;
    position: relative;
    .detail-status {
      position: absolute;
      top: 0;
      right: 0;
      width: 96rpx;
      height: 44rpx;
    }
    .detail-name {
      font-size: 28rpx;
      color: rgba(0,0,0,0.85);
      margin-bottom: 16rpx;
    }
    .detail-tel {
      font-size: 24rpx;
      color: rgba(0,0,0,0.25);
      margin-bottom: 32rpx;
    }
    .detail-box-title {
      display: flex;
      align-items: center;
      gap: 8rpx;
      margin-bottom: 28rpx;
      image {
        width: 32rpx;
        height: auto;
      }
      text {
        font-family: PingFang-SC, PingFang-SC;
        font-size: 24rpx;
        color: rgba(0,0,0,0.85);
      }
    }
    .detail-box-content {
      width: 100%;
      background: rgba(255,239,221,.5);
      border-radius: 16rpx;
      padding: 28rpx;
      line-height: 44rpx;
      font-size: 24rpx;
      font-family: PingFang-SC, PingFang-SC;
      .detail-box-item {
        font-family: PingFang-SC, PingFang-SC;
        margin-bottom: 16rpx;
        font-size: 24rpx;
        line-height: 34rpx;
      }
      .detail-box-item:last-child {
        margin-bottom: 0;
      }
    }
  }
  .contract-list {
    width: 686rpx;
    margin: 0 auto;
    .list-item {
      margin-bottom: 32rpx;
      width: 686rpx;
      background: #FFFFFF;
      box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(11,102,97,0.2);
      border-radius: 16rpx;
      padding: 48rpx 32rpx 40rpx;
      .list-title {
        display: flex;
        align-items: center;
        gap: 8rpx;
        margin-bottom: 32rpx;
        image {
          width: 32rpx;
          height: auto;
        }
        text {
          font-family: PingFang-SC, PingFang-SC;
          font-size: 24rpx;
          color: rgba(0,0,0,0.85);
        }
      }
      .info {
        height: 138rpx;
        margin-bottom: 48rpx;
        display: flex;
        gap: 24rpx;
        image {
          width: 104rpx;
          height: 104rpx;
          flex-shrink: 0;
        }
        .title {
          font-size: 28rpx;
          color: rgba(0,0,0,0.85);
          margin-bottom: 16rpx;
        }
        .time {
          font-size: 24rpx;
          color: rgba(0,0,0,0.25);
        }
        .status {
          padding: 0 20rpx;
          height: 44rpx;
          line-height: 40rpx;
          border-radius: 200rpx;
          border: 2rpx solid;
          font-family: PingFangSC, PingFang SC;
          font-size: 24rpx;
          flex-shrink: 0;
        }
      }
      .actions {
        display: flex;
        gap: 24rpx;
        .actions-item {
          flex: 1;
          height: 76rpx;
          border-radius: 8rpx;
          display: flex;
          align-items: center;
          justify-content: center;
          gap: 4rpx;
          font-family: PingFangSC, PingFang SC;
          font-size: 24rpx;
          image {
            width: 32rpx;
            height: 32rpx;
          }
        }
      }
    }
  }
}
</style>
